package com.pro.control;

import com.pro.entity.JsonData;
import com.pro.entity.OIndex;
import com.pro.service.OIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName: OIndexController
 * @Author: 笑笑
 * @DATE: 2021/12/3
 * @TIME: 下午 02:57
 */
@RestController
@RequestMapping("/OIndex")
public class OIndexController {
    @Autowired
    private OIndexService oIndexService;

    //根据视频字段统计其数量
    @RequestMapping("/getCourseField")
    public JsonData getCourseField(OIndex oIndex){
        OIndex courseField = oIndexService.getCourseField(oIndex);
        return courseField != null ? JsonData.buildSuccess(courseField) : JsonData.buildError("没有查到");
    }

    //统计上架课程或商品
    @RequestMapping("/getGoOnlineCount")
    public JsonData getGoOnlineCount(OIndex oIndex){
        OIndex courseField = oIndexService.getGoOnlineCount(oIndex);
        return courseField != null ? JsonData.buildSuccess(courseField) : JsonData.buildError("没有查到");
    }

    //根据用户创建时间统计用户数量
    @RequestMapping("/getBeforeUser")
    public JsonData getBeforeUser(OIndex oIndex){
        Integer beforeUser = oIndexService.getBeforeUser(oIndex);
        return beforeUser > 0 ? JsonData.buildSuccess(beforeUser) : JsonData.buildError("没有查到");
    }

    //每个小时内的创建总数
    @RequestMapping("/getCourseHours")
    public JsonData getCourseHours(){
        Map<String, Object> courseHours = oIndexService.getCourseHours();
        return courseHours.size() > 0 ? JsonData.buildSuccess(courseHours) : JsonData.buildError("没有查到");
    }

    //每个周内的创建总数
    @RequestMapping("/getCourseWeek")
    public JsonData getCourseWeek(){
        Map<String, Object> courseWeek = oIndexService.getCourseWeek();
        return courseWeek.size() > 0 ? JsonData.buildSuccess(courseWeek) : JsonData.buildError("没有查到");
    }

    //每个月中每天内的创建总数
    @RequestMapping("/getCourseDay")
    public JsonData getCourseDay(){
        Map<String, Object> courseDay = oIndexService.getCourseDay();
        return courseDay.size() > 0 ? JsonData.buildSuccess(courseDay) : JsonData.buildError("没有查到");
    }

    //统计每个月课程的总数
    @RequestMapping("/getCourseMonthSum")
    public JsonData getCourseMonthSum(){
        Map<String, Object> courseMonthSum = oIndexService.getCourseMonthSum();
        return courseMonthSum.size() > 0 ? JsonData.buildSuccess(courseMonthSum) : JsonData.buildError("没有查到");
    }
    
    //某个月课程申请成功的总数
    @RequestMapping("/getCourseAdopMonthSum")
    public JsonData getCourseAdopMonthSum(){
        Map<String, Object> courseAdopMonthSum = oIndexService.getCourseAdopMonthSum();
        return courseAdopMonthSum.size() > 0 ? JsonData.buildSuccess(courseAdopMonthSum) : JsonData.buildError("没有查到");
    }
}
